0 REM
5 CLEAR:GRAPH:CLS
40 DIM R%(53,24),SX%(47),SY%(47),X%,Y%,SL%,LM%,DX%,DY%,SC%,HN%,EN%,SP,SM,MX%
45 DIM HP%,EK,EC,HM%,BM%,T$(4),T%(4),P$,S%
80 LOCATE 1,7:PRINT "暴走蛇II","1.开始玩","2.排行榜";
81 LOCATE 5,13:PRINT "Ver1.02";
100 K=ASC(INKEY$)
110 IF K=98 THEN 220
120 IF K=110 THEN 5000
125 IF K=27 THEN CLS:PRINT "天天副食编写","QQ:22062019":END
130 GOTO 100
220 SL%=7:LM%=20:DX%=1:DY%=0:SC%=0:SN%=7:EN%=0:X%=5:Y%=12:HP%=50:EK=0:EC=0:HM%=50:BM%=0
230 SM=0:SP=50:MX%=47:R%(0,0)=1
900 CLS:LINE 1,7,159,7,1:GOSUB 2320:LINE 53,4,103,4,1:LINE 10,5,24,5,1
930 FD=5:GOSUB 3000
1000 __DELAY 500:FOR I=1 TO SP:A=PEEK(199):IF A>128 THEN __DELAY 0:GOTO 2000
1005 NEXT:__DELAY 0
1010 X%=X%+DX%
1020 Y%=Y%+DY%
1021 IF X%>52 THEN X%=0
1022 IF X%<0 THEN X%=52
1023 IF Y%>23 THEN Y%=0
1024 IF Y%<0 THEN Y%=23
1030 IF R%(X%,Y%)>0 THEN TD=R%(X%,Y%):GOTO 2200
1040 BOX SX%(EN%)*3+1,SY%(EN%)*3+8,SX%(EN%)*3+3,SY%(EN%)*3+10,1,0
1045 REM __DEBUG SY%(EN%)*3,SX%(EN%)*3+1;",";SY%(EN%)*3+8;",";SX%(EN%)*3+3;",";SY%(EN%)*3+10
1050 BOX X%*3+1,Y%*3+8,X%*3+3,Y%*3+10,1,1
1100 SN%=SN%+1
1110 IF SN%>MX% THEN SN%=0
1115 SX%(SN%)=X%:SY%(SN%)=Y%
1120 EN%=SN%-SL%
1130 IF EN%<0 THEN EN%=EN%+MX%+1
1140 R%(X%,Y%)=1:R%(SX%(EN%),SY%(EN%))=0
1800 REM __DELAY 1000:FOR N=1 TO SP:NEXT N:__DELAY 0
1900 GOTO 1000
2000 K=A-128:POKE 199,0:REM K=ASC(INKEY$)
2010 IF K=20AND DY%=0 THEN DX%=0:DY%=-1:GOTO 1010
2020 IF K=21 AND DY%=0 THEN DX%=0:DY%=1:GOTO 1010
2030 IF K=23 AND DX%=0 THEN DX%=-1:DY%=0:GOTO 1010
2040 IF K=22 AND DX%=0 THEN DX%=1:DY%=0:GOTO 1010
2050 IF K=112 THEN 2800
2060 IF K=113 OR K=27 THEN 0
2100 GOTO 1010
2200 IF TD<3 THEN 2210
2201 IF SP=0 THEN SC%=SC%+5:SM=SM-0.1 ELSE SP=SP-0.1:GOTO 2203
2202 IF TD=4 AND EK=4 AND EC=1 THEN SWAP SP,SM:FS=0
2203 IF EK=TD THEN EC=EC+1:GOTO 2400 ELSE EK=TD:EC=1:GOSUB 2450:GOTO 2400
2204 IF EC=5 THEN EC=0:EK=0:SC%=SC%+10:GOSUB 2450:GOTO 2209
2205 SC%=SC%+5:SL%=SL%+2:FD=1:GOSUB 2500
2207 IF SP<15 AND FS=0 THEN SP=15
2208 GOTO 1040
2209 ON TD-2 GOTO 2220,2230,2240,2250,2260
2210 IF BM%=0 THEN 2213
2211 R%(X%,Y%)=0:GOSUB 2710:BM%=0:SL%=4:GOSUB 2800:GOTO 1040
2213 HP%=HP%-1:IF HP%<0 THEN HP%=0:LOCATE 3,6:PRINT "Score:";SC%:GOTO 2900
2214 X%=X%-DX%:Y%=Y%-DY%:GOSUB 2300:GOTO 1000
2220 FD=3:GOSUB 3000:GOTO 2205
2230 FOR N=1 TO 4:BOX 1,8,159,79,1,2:FOR NN=1 TO 30:NEXT NN:NEXT N
2231 SWAP SP,SM:FS=1:GOTO 2205
2240 FOR N=1 TO 8:BOX 1,8,159,79,1,2:FOR NN=1 TO 0:NEXT NN:NEXT N
2241 GOSUB 2600:GOTO 2205
2250 IF HP%=HM% THEN SC%=SC%+40
2251 HP%=HP%+15:IF HP%>HM% THEN HP%=HM%
2255 GOSUB 2320:GOTO 2205
2260 GOSUB 2700:GOTO 2205
2300 BOX 103,2,HP%+53,3,1,0
2310 RETURN
2320 BOX 53,2,HP%+53,3,1,1
2330 RETURN
2400 TA=EC+2:TC=EK:TB=-2:GOSUB 3500:GOTO 2204
2450 BOX 10,2,24,4,1,0:RETURN
2500 IF SL%>47 THEN SL%=7 ELSE 2510
2503 FOR N=0TO 47:R%(SX%(N),SY%(N))=2:NEXT N
2504 R%(SX%(EN%),SY%(EN%))=0
2510 FD=1:GOSUB 3000:RETURN
2600 IF SL%>29 THEN TA=24 ELSE TA=SL%-5
2610 FOR N=EN%TO EN%+TA
2615 NN=N:IF NN>MX% THEN NN=NN-MX%-1
2620 BOX SX%(NN)*3+1,SY%(NN)*3+8,SX%(NN)*3+3,SY%(NN)*3+10,1,0
2630 R%(SX%(NN),SY%(NN))=0
2640 NEXT N
2650 SL%=SL%-TA
2660 RETURN
2700 GOSUB 2780
2710 FOR N=0TO 52
2720 IF R%(N,Y%)=2 THEN R%(N,Y%)=0:BOX N*3+1,Y%*3+8,N*3+3,Y%*3+10,1,2
2730 NEXT N
2740 FOR N=0TO 23
2750 IF R%(X%,N)=2 THEN R%(X%,N)=0:BOX X%*3+1,N*3+8,X%*3+3,N*3+10,1,2
2760 NEXT N
2770 GOSUB 2780:RETURN
2780 BOX 1,8,159,79,1,2:BOX X%*3+1,8,X%*3+3,79,1,2:BOX 1,Y%*3+8,159,Y%*3+10,1,2
2790 RETURN
2800 TA=105:TB=1:GOSUB 4500:GOSUB 2850
2805 FOR N=1 TO 2:BOX X%*3+1,Y%*3+8,X%*3+3,Y%*3+10,1,2:FOR NN=1 TO 250:NEXT NN:NEXT N
2810 IF PEEK(199)>128 THEN S$=INKEY$:K=ASC(S$):BOX 105,1,159,5,1,0ELSE 2805
2820 IF K=112 THEN K=0
2830 GOTO 2010
2850 IF PEEK(199)>128 THEN S$=INKEY$
2851 RETURN
2900 OPEN "BZST_DAT" FOR OUTPUT AS 1
2910 WRITE#1,SC%:CLOSE 1:S$=INKEY$
2930 GOTO 5000
3000 IF FD>0 THEN FD=FD-1:GOSUB 3100
3010 RETURN
3100 TA=INT(RND(1)*53):TB=INT(RND(1)*24)
3105 IF R%(TA,TB)<>0 OR TA=0 AND TB=0 THEN 3100
3110 TC=INT(RND(1)*9/2)+3:R%(TA,TB)=TC:GOSUB 3500
3120 GOTO 3000
3500 ON TC-2 GOTO 3510,3520,3530,3540,3550
3510 BOX TA*3+1,TB*3+8,TA*3+3,TB*3+10,0,2:DRAW TA*3+2,TB*3+9,2:RETURN
3520 BOX TA*3+1,TB*3+8,TA*3+3,TB*3+10,1,2
3521 BOX TA*3+1,TB*3+8,TA*3+3,TB*3+10,0,2:RETURN
3530 BOX TA*3+1,TB*3+8,TA*3+3,TB*3+10,0,1:RETURN
3540 LINE TA*3+1,TB*3+8,TA*3+1,TB*3+9,2
3541 LINE TA*3+3,TB*3+8,TA*3+3,TB*3+9,2
3542 LINE TA*3+2,TB*3+9,TA*3+2,TB*3+10,2:RETURN
3550 BOX TA*3+1,TB*3+8,TA*3+2,TB*3+9,1,2
3551 DRAW TA*3+3,TB*3+10,2
3552 RETURN
4300 BOX TA,TB,TA+2,TB+4,1,1
4305 ON TC+1 GOTO 4400,4410,4420,4430,4440,4450,4460,4470,4480,4490
4400 LINE TA+1,TB+1,TA+1,TB+3,0:RETURN
4410 LINE TA,TB,TA,TB+4,0
4411 LINE TA+2,TB,TA+2,TB+4,0:RETURN
4420 LINE TA,TB+1,TA+1,TB+1,0
4421 LINE TA+1,TB+3,TA+2,TB+3,0:RETURN
4430 LINE TA,TB+1,TA+1,TB+1,0
4431 LINE TA,TB+3,TA+1,TB+3,0:RETURN
4440 LINE TA+1,TB,TA+1,TB+1,0
4441 BOX TA,TB+3,TA+1,TB+4,1,0:RETURN
4450 LINE TA+1,TB+1,TA+2,TB+1,0
4451 LINE TA,TB+3,TA+1,TB+3,0:RETURN
4460 LINE TA+1,TB+1,TA+2,TB+1,0
4461 DRAW TA+1,TB+3,0:RETURN
4470 BOX TA,TB+1,TA+1,TB+4,1,0:RETURN
4480 DRAW TA+1,TB+1,0
4481 DRAW TA+1,TB+3,0:RETURN
4490 LINE TA,TB+3,TA+1,TB+3,0
4491 DRAW TA+1,TB+1,0:RETURN
4499 GRAPH:CLS
4500 TD=INT(SC%/1000)
4510 TE=INT((SC%-TD*1000)/100)
4520 TF=INT((SC%-TD*1000-TE*100)/10)
4530 TG=SC%-TD*1000-TE*100-TF*10
4540 TB=1
4550 TA=130:TC=TD:GOSUB 4300
4560 TA=134:TC=TE:GOSUB 4300
4570 TA=138:TC=TF:GOSUB 4300
4580 TA=142:TC=TG:GOSUB 4300
4690 RETURN
5000 CLEAR:CLS:PRINT "Wait...";
5002 FN$="BZST_TOP"
5005 OPEN FN$ FOR RANDOM AS #1
5006 TA=LOF(1)
5008 CLOSE#1
5009 IF TA=0 THEN GOSUB 5400
5010 OPEN FN$ FOR INPUT AS1
5020 FOR N=1 TO 4
5030 INPUT#1,T$(N),T%(N)
5040 NEXT N
5060 CLOSE 1
5061 OPEN "BZST_DAT" FOR RANDOM AS 1:TA=LOF(1):CLOSE 1
5062 IF TA=0 THEN S%=0:GOTO 5100
5070 OPEN "BZST_DAT" FOR INPUT AS1
5080 INPUT#1,S%
5090 CLOSE 1
5095 OPEN "BZST_DAT" FOR OUTPUT AS 1:WRITE#1,0:CLOSE 1
5100 IF S%<=T%(4) THEN 5200
5105 TEXT:CLS:PRINT "进榜啦!","留下大名:";:INPUT "";P$
5106 P$=MID$(P$+" ",1,12)
5110 FOR N=1 TO 4
5120 IF S%>T%(N) THEN SWAP T$(N),P$:SWAP T%(N),S%
5130 NEXT N
5140 GOSUB 5300
5200 GRAPH:CLS:PRINT "排行榜";:FOR N=1 TO 4
5205 LOCATE N+1,1:PRINT N;".";T$(N);" ";TAB (16);T%(N);:NEXT N
5210 S$=INKEY$
5240 GOTO 0
5250 REM
5300 OPEN FN$ FOR OUTPUT AS 1
5310 FOR N=1 TO 4:WRITE#1,T$(N),T%(N):NEXT N
5320 CLOSE 1:RETURN
5400 FOR N=1 TO 4:T$(N)="无人上榜":T%(N)=0:NEXT N
5410 GOSUB 5300
5420 RETURN

